#include "core.h"

CIndexRecreate::CIndexRecreate()
{
	Initialize("");
}

CIndexRecreate::~CIndexRecreate()
{

}

CIndexRecreate* CIndexRecreate::getInstance()
{
	static CIndexRecreate *p = NULL;
	if (!p)
	{
		p = new CIndexRecreate;
	}
	return p;
}

bool CIndexRecreate::Initialize(std::string host)
{
	m_strUrl = "http://";
	m_strUrl += host;
	m_strUrl += "/index";
	return true;
}

bool CIndexRecreate::Destory()
{
	delete this;
	return true;
}

STCreateTaskResponse* CIndexRecreate::createTask(STCreateTaskRequest *pRequest)
{
	std::string requestUrl = m_strUrl;
	requestUrl += "/";
	requestUrl += pRequest->appname;
	m_mapRequestParameter = mapRequestParameter;
	m_vecRequestParameter = vecRequestParameter;
	addQuerryParameter("action", pRequest->action, m_mapRequestParameter, m_vecRequestParameter);
	addQuerryParameter("operate", pRequest->operate, m_mapRequestParameter, m_vecRequestParameter);
	addQuerryParameter("table_name", pRequest->table_name, m_mapRequestParameter, m_vecRequestParameter);

	std::string strtmp = "";
	if (!Request(requestUrl, "GET", GetQuerryParameter(m_mapRequestParameter, m_vecRequestParameter, "GET", strtmp)))
	{
		printf("[%s]:%d\n", __FUNCTION__, __LINE__);
		return NULL;
	}

	createTaskResponse();
	return &m_createTaskResponse;
}

bool CIndexRecreate::createTaskResponse()
{
	return true;
}